//
//  UIScrollView+YQRefresh.m
//  first
//
//  Created by 毕小强 on 16/11/8.
//  Copyright © 2016年 毕小强. All rights reserved.
//

#import "UIScrollView+YQRefresh.h"


#import <objc/runtime.h>

@implementation UIScrollView (YQRefresh)
///添加头视图
-(void)addYQRefreshHeadTarget:(id)target headerSelect:(SEL)headerSelect{
    YQRefreshHeadView *headerView = [[YQRefreshHeadView alloc]initWithFrame:CGRectMake(0, -kRefreshViewHeight, self.bounds.size.width, kRefreshViewHeight)];
    headerView.selecterTarget = target;
    headerView.refreshSelector = headerSelect;
    headerView.superScrollView = self;
    self.head = headerView;
    [self addSubview:headerView];
}
//添加尾视图
-(void)addYQRefreshFootTarget:(id)target footerSelect:(SEL)footerSelect{
    YQRefreshFootView *footerView = [[YQRefreshFootView alloc]initWithFrame:CGRectMake(0, -kRefreshViewHeight, self.bounds.size.width, kRefreshViewHeight)];
    footerView.selecterTarget = target;
    footerView.refreshSelector = footerSelect;
    footerView.superScrollView = self;
    self.foot = footerView;
    [self addSubview:footerView];
}

-(YQRefreshHeadView*)head{
   return objc_getAssociatedObject(self, "head");
}
-(void)setHead:(UIView *)head{
    objc_setAssociatedObject(self, "head", head, OBJC_ASSOCIATION_ASSIGN);
}

-(YQRefreshFootView*)foot{
    return objc_getAssociatedObject(self, "foot");
}
-(void)setFoot:(UIView *)foot{
    objc_setAssociatedObject(self, "foot", foot, OBJC_ASSOCIATION_ASSIGN);
}
@end
